package com.wanhelibs;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebSettings;

import com.github.lzyzsd.jsbridge.BridgeHandler;
import com.github.lzyzsd.jsbridge.BridgeWebView;
import com.github.lzyzsd.jsbridge.CallBackFunction;

public class TestActivity extends Activity {

    BridgeWebView webView;

    public static void startTestActivity(Activity act) {
        Intent intent = new Intent(act, TestActivity.class);
        act.startActivity(intent);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        webView = (BridgeWebView) findViewById(R.id.webView);
        webView.setKeepScreenOn(false);
        WebSettings settings = webView.getSettings();
        settings.setDomStorageEnabled(true);
        settings.setAppCacheMaxSize(1024 * 1024 * 8);
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        settings.setBuiltInZoomControls(true);
        settings.setSupportZoom(true);
        settings.setJavaScriptEnabled(true);
        settings.setAppCacheEnabled(true);
        settings.setCacheMode(WebSettings.LOAD_DEFAULT);
        settings.setAllowFileAccess(true);
        webView.loadUrl("file:///storage/emulated/0/wanheh5/Padadd.html");

//        boolean id = webView.isHardwareAccelerated();
        webView.registerHandler("getPadID", new BridgeHandler() {
            @Override
            public void handler(String data, CallBackFunction function) {
                Log.e("MainActivity", "GetAll");
                function.onCallBack("test androidId");
            }
        });
    }
}
